<script>
export default {
  name: "PersonalPostView",
  data() {
    return {
      c: {title:"",type:"1",categoryId:""},
      dialogImageUrl: '',
      dialogVisible: false
    }
  },
  methods: {
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    }
  },
  mounted() {  //页面元素加载完成并且Vue框架和元素挂载完成后调用的方法
    //通常在此处做一些初始化操作,比如富文本编辑器初始化, 或者发请求的代码
    //初始化富文本编辑器
    this.editor = new this.wangEditor("#content_div");
    this.editor.create();
  }
}
</script>

<template>
  <div>
    <h1 style="color: orange">发布页面</h1>
    <el-form label-width="80px">
      <el-form-item label="文章标题">
        <el-input placeholder="请输入文章标题" v-model="c.title"></el-input>
      </el-form-item>
      <el-form-item label="文章分类">
        <el-radio-group v-model="c.type">
          <el-radio-button label="1">烘焙食谱</el-radio-button>
          <el-radio-button label="2">烘焙视频</el-radio-button>
          <el-radio-button label="3">行业资讯</el-radio-button>
        </el-radio-group>
      </el-form-item>

    <el-form-item label="二级分类">
      <el-select v-model="c.categoryId">
        <el-option label="面包" value="1"></el-option>
        <el-option label="小食" value="2"></el-option>
        <el-option label="家常菜" value="3"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="封面">
      <el-upload
          action="https://jsonplaceholder.typicode.com/posts/"
          list-type="picture-card"
          :on-preview="handlePictureCardPreview"
          :on-remove="handleRemove">
        <i class="el-icon-plus"></i>
      </el-upload>
      <el-dialog :visible.sync="dialogVisible">
        <img width="100%" :src="dialogImageUrl" alt="">
      </el-dialog>
    </el-form-item>
    <el-form-item label="文章内容">
      <div id="content_div"></div>
    </el-form-item>
      <el-form-item>
        <el-button type="success">发布</el-button>
      </el-form-item>

    </el-form>
  </div>
</template>

<style scoped>

</style>